package basic.basic_class04;

//折纸问题
public class CutPaper {
    public static void printCur(int n){
        String[] process = process(n);
        for (String s : process) {
            System.out.println(s);
        }
    }

    // 返回每次打印的数组
    public static String[] process(int n){
        String[] choice = new String[]{"down","up"};
        if(n == 1) return new String[]{"down"};
        String[] res = new String[(1 << n) - 1];
        String[] pre = process(n - 1);
        int preindex = 0;
        for (int i = 0; i < res.length; i++) {
            res[i] = i % 2 == 0 ? choice[(i/2) % 2] : pre[preindex++];
        }
        return res;
    }

    public static void main(String[] args) {
        printCur(3);
    }

}
